package socketServer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;

public class SocketServerTest {

	public static void main(String args[]){
		
		try {
			ServerSocket serverSocket = new ServerSocket(4700);
			Socket socket = serverSocket.accept();
			
			PrintWriter writer = new PrintWriter(socket.getOutputStream());
			BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
			
			writer.write("涂有，哈哈");
			System.out.println(reader.readLine());
			
			reader.close();
			writer.close();
			socket.close();
			serverSocket.close();
		} catch (SocketException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
